﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 软构第一次作业
{
    class demo
    {
        public List<int> primelist = new List<int>();
        public int length()
        {
            return primelist.Count;
        }
        public int Getmax(int[] n)
        {
            int max = n[0];
            for (int i = 0; i < n.Length; i++)
            {
                if (max < n[i])
                {
                    max = n[i];
                }
            }

            return max;
        }
        public int Getmin(int[] n)
        {
            int min = n[0];
            for (int i = 0; i < n.Length; i++)
            {
                if (min>n[i])
                {
                    min = n[i];
                }
            }
            return min;
        }
        public int Getavg(int[] n)
        {
            int avg = Getsum(n)/(n.Length+1);
            return avg;
        }
        public int  Getsum(int[] n)
        {
            int sum = 0;
            for(int i = 0; i < n.Length; i++)
            {
                sum = sum + n[i];
            }
            return sum;
        }

        bool Judgeprime(int n)
        {
            int flag = 0;
            for(int i = 2; i < n; i++)
            {
                if (n%i==0)
                {
                    flag++;
                }
            }
            if (flag == 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public void getallprime(int a,int b)
        {
            int nl = 0;//设置换行标志位
            for(int i = a; i<=b ;i++)
            {
                if(nl == 10)
                {
                    nl = 0;
                    Console.WriteLine("\r\n");
                }
                if (Judgeprime(i))
                {
                    primelist.Add(i);
                    nl++;
                }
            }
        }
    }
}
